<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        button {
            margin: 1px 2px;
        }
    </style>
</head>
<input id="result">
<body>
    <table border="2" cellspadding="2" >
        <tr>
            <td>
                <button onclick="s1()">1</button><button onclick="s2()">2</button><button onclick="s3()">3</button><button onclick="jia()">+</button>
            </td>
        </tr>
        <tr>
            <td>
                <button onclick="s4()">4</button><button onclick="s5()">5</button><button onclick="s6()">6</button><button onclick="jian()">-</button>
            </td>
        </tr>
        <tr>
            <td>
                <button onclick="s7()">7</button><button onclick="s8()">8</button><button onclick="s9()">9</button><button onclick="chen()">*</button>
            </td>
        </tr>
        <tr>
            <td>
                <button onclick="s0()">0</button><button onclick="dian()">.</button><button onclick="dengyu()">=</button><button onclick="chu()">%</button>
            </td>
        </tr>
                        
    </table>


    <script>
        var i
        var numl

        function s0(){
            result.value = "";
        }
        function s1(){
            result.value = result.value+1;
        }
        function s2(){
            result.value = result.value+2;
        }
        function s3(){
            result.value = result.value+3;
        }
        function s4(){
            result.value = result.value+4;
        }
        function s5(){
            result.value = result.value+5;
        }
        function s6(){
            result.value = result.value+6;
        }
        function s7(){
            result.value = result.value+7;
        }
        function s8(){
            result.value = result.value+8;
        }
        function s9(){
            result.value = result.value+9;
        }
        function jia(){
            num1 = parseFloat(result.value);
            result.value = "";
            i=1;
        }
        function jian(){
            num1 = parseFloat(result.value);
            result.value = "";
            i=2;
        }
        function cheng(){
            num1 = parseFloat(result.value);
            result.value = "";
            i=3;
        }
        function chu(){
            num1 = parseFloat(result.value);
            result.value = "";
            i=4;
        }
        function dengyu(){
            if(i==1){
            result.value = num1+parseFloat(result.value);
            }
            if(i==2){
                result.value = num1-parseFloat(result.value);
            }
            if(i==3){
                result.value = num1*parseFloat(result.value);
            }
            if(i==4){
                result.value = num1/parseFloat(result.value);
            }
        }
        
    </script>



</body>
</html>